doctype html
html
	head
		meta(charset="utf-8")
		meta(name="renderer" content="webkit")
		meta(http-equiv="Access-Control-Allow-Origin" content="*")
		meta(http-equiv="X-UA-Compatible" content="IE=EmulateIE11")
		meta(name="viewport" content="width=device-width, initial-scale=1.0")
		meta(name="description" content="标识汇")
		meta(name="keyword" content="标识汇")
		title 标识汇-登录
		link(href="${relativePath}/static/css/common.css" type="text/css" rel="stylesheet")
		link(href="${relativePath}/static/css/login.css" type="text/css" rel="stylesheet")
	body
		div.layout.login-container
			//- 头部
			header
				div.logo.fl
					img(src="${relativePath}/static/imgs/logo.png")
				div.right-nav.fr
					ul
						li
							a(href="#") 您好！欢迎登录标识汇!
						li
							a.login-btn(href="login.html") 请登录
						li
							a(href="#") 帮助中心
						li
							a(href="#") 关于我们
						li
							a(href="#") 联系我们
						li
							a.service(href="#") 客服
		//- banner
		div.banner
			div.banner_inner.layout
				div.left_img
					img(src="${relativePath}/static/imgs/circle.png")
				div.right_box.rightLogin.fr
					form(name="regist").login-box#regist
						input#saveData(type="hidden")
						div.loginbigBox
							a.codeLogin#codeLogin.fr(href="javascript:;") 扫码登录
							div.fl_wrap
								input.phone_num#user(type="text" name="phone_num" placeholder="请输入手机号")
							div.fl_wrap
								input.password#pass(type="password" name="password" placeholder="请输入密码")
							//- div.fl_wrap
							//- 	input.password_pre(name="password_pre" type="password" placeholder="请输入验证码")
							//- div.fl_wrap.lookImg
							//- 	img(src="../static/imgs/codes.png")#verify
							//- 	span.change 看不清，换一张
							span.agree.remPass
								label
									input.rememberPsw(type="checkbox" name="rememberPsw" checked)
									| &nbsp;记住密码
								a.forgetPsw(href="forgetPsw.html") 忘记密码
							a.regBtn(href="javascript:;") 登 录
						div.codesimg
							a.codeLogin#countLogin.fr(href="javascript:;") 账号登录
							div.codeChange
								img#changeCodeimg(src="")
								div.maskcode 点击重新生成二维码
						label.noNumber 没有账号？
							a(href="regist.html") 立即注册
		//- list-nav
		div.list-nav
			ul
				li
					a(href="javascript:;")
						img(src="${relativePath}/static/imgs/trade.png")
						p 行业交易
				li
					a(href="javascript:;")
						img(src="${relativePath}/static/imgs/information.png")
						p 社区资讯
				li
					a(href="javascript:;")
						img(src="${relativePath}/static/imgs/oa.png")
						p 办公OA
				li
					a(href="javascript:;")
						img(src="${relativePath}/static/imgs/erp.png")
						p 业务管理
				li
					a(href="javascript:;")
						img(src="${relativePath}/static/imgs/bjzs.png")
						p 报价助手
		//- 底部
		div.footer
			div.footer-inner
				div.left
					p 标识汇官网|成品材料|定制加工|需求中心|社区资讯|工作ERP|办公OA微单系统
					<a href="http://www.miitbeian.gov.cn" target="_blank" style="color:#999"> @copy;2015标识汇  豫ICP备16000399号-2</a>
					p 版权所有：标识汇网络技术有限公司
				div.code
					div.code_1
						img(src="${relativePath}/static/imgs/code_1.png")
						p 下载手机标识汇
					div.code_2
						img(src="${relativePath}/static/imgs/code_2.png")
						p 关注微信公众号

block pageScript
	script(type="text/javascript" src="${relativePath}/static/js/jquery.min.js")
	script(type="text/javascript" src="${relativePath}/static/js/libs/jquery.cookie.js")
	script(type="text/javascript" src="${relativePath}/static/js/common.js")
	script(type="text/javascript" src="${relativePath}/static/js/jquery.validate.min.js")
	script(type="text/javascript" src="${relativePath}/static/js/messages_zh.js")
	script(src="${relativePath}/static/js/libs/layer/layer.js")
	script.
		$(function(){
			// 手机号码验证
			jQuery.validator.addMethod("isMobile", function(value, element) {
				var length = value.length;
				var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
				return this.optional(element) || (length == 11 && mobile.test(value));
			}, "请正确填写您的手机号码");
			var validator = $("#regist").validate({
					rules: {
						phone_num:{
							required:true,
							isMobile:true
						},
						password:{
							required: true
						}
					},
					messages : {
				        phone_num:{
				        	required:'请输入手机号'
				        },
				        password:{
				        	required:'请输入密码'
				        }
				    },
				});

			//- 点击记录密码
			var strName = localStorage.getItem('keyName');
			var strPass = localStorage.getItem('keyPass');
			if(strName){
				$('#user').val(strName);
			}
			if(strPass){
				$('#pass').val(strPass);
				$('.rememberPsw').attr('check',"checked");
			}

			function loginBtn_click(){
				var strName = $('#user').val();
				var strPass = $('#pass').val();
				localStorage.setItem('keyName',strName);
				if($('.rememberPsw').is(':checked')){
					localStorage.setItem('keyPass',strPass);
				}else{
					localStorage.removeItem('keyPass');
				}
			}
			//- 点击登录
			$(".regBtn").click(function(){
				if(validator.form()){
					//验证通过再保存
					loginBtn_click();
					$.ajax({
						url:shopIp+'/account/login',
						data:{
							phone:$(".phone_num").val(),
							password:$(".password").val(),
							os:"web"
						},
						dataType: "jsonp",
						type:"post"
					}).done(function(data){
						if(data.status == "200"){
							//- $.cookie("userToken",data.data.token, {expires: 7,path: '/'});
							window.location.href="../view/shopping/materIndex.html?token="+data.data.token;
						}else{
							layer.msg(data.msg);
						}
					})
				}
			})
			//- 鼠标回车登陆
			$("body").keydown(function(event) {
				if(event.keyCode == "13") {
					if(validator.form()){
						//验证通过再保存
						loginBtn_click();
						$.ajax({
							url:shopIp+'/account/login',
							data:{
								phone:$(".phone_num").val(),
								password:$(".password").val(),
								os:"web"
							},
							dataType: "jsonp",
							type:"post"
						}).done(function(data){
							if(data.status == "200"){
								window.location.href="../view/shopping/materIndex.html?token="+data.data.token;
							}else{
								layer.msg(data.msg);
							}
						})
					}
				}
			})
			//- 点击扫码登录
			var t;
			$("#codeLogin").click(function() {
				var time = new Date();
				function getCode() {
					$.ajax({
						url:shopIp+'/account/makeqrlogin?callback=?&os=web&addtime='+time,
						type:'get',
						dataType: "jsonp",
						success:function(data) {
							console.log(data);
							if(data.status == '200') {
								$("#changeCodeimg").attr("src",data.data.qrpic);
								$("#saveData").attr({
									"ids":data.data.id,
									"sign":data.data.sign
								});
							}else{
								layer.msg(data.msg);
							}
						}
					})
				}
				getCode();
				setInterval(function() {
					//getCode()
					$(".maskcode").show();
					$(".maskcode").click(function() {
						$(".maskcode").hide()
						getCode();
					})
				},180000)
				$(".codesimg").show();
				$(".loginbigBox").hide();
				var times = 0;
				t = setInterval(function() {
				    if(times * 2 >= 180) {
				        clearInterval(t);
				        return;
				    }
				    getData();
				    times ++;
				}, 2000);
				function getData() {
					$.getJSON(shopIp+'/account/loginajax_return?os=web&callback=?&id='+$("#saveData").attr("ids")+'&sign='+$("#saveData").attr('sign'),function(data) {
						//console.log(data);
						if(data.msg == "登陆成功") {
							clearInterval(t);
							window.location.href="../view/shopping/materIndex.html?token="+data.data.token;
						}else{
							//layer.msg(data.msg);
						}
					})
				}
			})
			$("#countLogin").click(function() {
				$(".loginbigBox").show();
				$(".codesimg").hide();
				clearInterval(t);
			})
		})




